/*
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: FuturesApi.java
 *   @Date: 19-6-23 上午11:20
 *   @Author: ppzhao
 *   @Description:
 *   @Copyright（C）: 2019 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 */

package io.bhex.sdk.trade.futures;

import android.text.TextUtils;

import java.util.List;

import io.bhex.baselib.constant.AppData;
import io.bhex.baselib.constant.Fields;
import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.GetParams;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.baselib.network.response.ResultResponse;
import io.bhex.sdk.Urls;
import io.bhex.sdk.account.UserInfo;
import io.bhex.sdk.data_manager.TradeDataManager;
import io.bhex.sdk.quote.bean.FuturesSymbolStatusBean;
import io.bhex.sdk.socket.NetWorkObserver;
import io.bhex.sdk.trade.bean.AssetRecordResponse;
import io.bhex.sdk.trade.bean.CalculateLiquidationPriceResponse;
import io.bhex.sdk.trade.bean.CalculateProfitResponse;
import io.bhex.sdk.trade.bean.FuturesAssetListResponse;
import io.bhex.sdk.trade.bean.FuturesAssetListSocketResponse;
import io.bhex.sdk.trade.bean.FuturesCreateOrderConfigResponse;
import io.bhex.sdk.trade.bean.FuturesFundingRatesResponse;
import io.bhex.sdk.trade.bean.IndicesResponse;
import io.bhex.sdk.trade.futures.bean.DeliveryOrderResponse;
import io.bhex.sdk.trade.futures.bean.DeliveryRecordResponse;
import io.bhex.sdk.trade.futures.bean.EntrustOrderResponse;
import io.bhex.sdk.trade.futures.bean.FutureStopProfitLossInfo;
import io.bhex.sdk.trade.futures.bean.FuturesOrderResponse;
import io.bhex.sdk.trade.futures.bean.FuturesPositionOrderResponse;
import io.bhex.sdk.trade.futures.bean.OrderCreateParams;
import io.bhex.sdk.trade.futures.bean.TradableBean;
import io.bhex.sdk.trade.futures.bean.TradableBeanResponse;

public class FuturesApi {
    public static void SubFuturesBalanceData(final NetWorkObserver<List<FuturesAssetListResponse.FuturesAssetBean>> observer) {
        if (UserInfo.isLogin() == false)
            return;

        TradeDataManager.GetInstance().RequestFuturesBalance(new NetWorkObserver<FuturesAssetListSocketResponse>() {

            @Override
            public void onShowUI(FuturesAssetListSocketResponse response) {
                if (response != null && response.data != null) {
                    if (observer != null)
                        observer.onShowUI(response.data);
                }
            }

            @Override
            public void onError(String response) {
                if (observer != null)
                    observer.onError(response);

            }
        }, new NetWorkObserver<FuturesAssetListResponse>() {

            @Override
            public void onShowUI(FuturesAssetListResponse response) {
                if (response != null && response.array != null) {
                    if (observer != null)
                        observer.onShowUI(response.array);
                }
            }

            @Override
            public void onError(String response) {
                if (observer != null)
                    observer.onError(response);
            }
        });
    }

    /**
     * RequestBalanceData
     *
     * @param observer
     */
    public static void RequestFuturesBalanceData(SimpleResponseListener<FuturesAssetListResponse> observer) {
        if (UserInfo.isLogin() == false)
            return;

        TradeDataManager.GetInstance().getRequestFuturesCurrentBalance(observer);

        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_ASSET_AVAILABLE)
                .addParam(Fields.FIELD_ACCOUNT_ID, UserInfo.getDefaultAccountId())
//                .addParam(Fields.FIELD_SYMBOL, )

//                .addParam(Fields.FIELD_ORDER_ID_PAGE,)
//                .addParam(Fields.FIELD_START_TIME,)
//                .addParam(Fields.FIELD_END_TIME,)
                .build();
        HttpUtils.getInstance().request(params, FuturesAssetListResponse.class, observer);
    }

    /**
     * RequestTokenBalance  should not Unsub
     *
     * @param token
     * @param observer
     */
    public static void SubFutureTokenBalanceChange(String token, SimpleResponseListener<FuturesAssetListResponse.FuturesAssetBean> observer) {
        if (UserInfo.isLogin() == false)
            return;

        TradeDataManager.GetInstance().RequestFuturesTokenBalance(token, observer);
    }

    /**
     * 获取期货可交易信息  should not Unsub
     *
     * @param tokenId
     * @param observer
     */
    public static void SubFutureTradableInfo(String tokenId, SimpleResponseListener<TradableBean> observer) {
        if (UserInfo.isLogin() == false)
            return;

        TradeDataManager.GetInstance().RequestFuturesTradableInfo(tokenId,observer);
    }


    /**
     * 期货资产流水
     *
     * @param token
     * @param pageId
     * @param observer
     */
    public static void RequestFuturesAssetDetail(String token, String pageId, SimpleResponseListener<AssetRecordResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_ASSET_DETAIL)
                .addParam(Fields.FIELD_ACCOUNT_ID, UserInfo.getDefaultAccountId())
                .addParam(Fields.FIELD_LIMIT, AppData.Config.PAGE_LIMIT);
        if (!TextUtils.isEmpty(token))
            builder.addParam("token_id", token);
        if (!TextUtils.isEmpty(pageId))
            builder.addParam(Fields.FIELD_ORDER_ID_PAGE_FROM, pageId);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, AssetRecordResponse.class, observer);

    }

    /**
     * 行情指数 （和OptionApi.RequestOptionIndices()接口一致）
     *
     * @param symbolId
     * @param observer
     */
    public static void RequestIndices(String symbolId, SimpleResponseListener<IndicesResponse> observer) {
        if (TextUtils.isEmpty(symbolId))
            return;
        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_OPTION_INDICES)
                .addParam("symbol", symbolId);

        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, IndicesResponse.class, observer);
    }

    /**
     * 请求期货交割状态
     *
     * @param symbol_ids
     * @param observer
     */
    public static void RequestFuturesStatus(String symbol_ids, SimpleResponseListener<FuturesSymbolStatusBean> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_OPTION_STATUS)
                .addParam("symbol_ids", symbol_ids)
                .build();
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, FuturesSymbolStatusBean.class, observer);

    }

    /** 订单SOCKET订阅 **************************************/

    /**
     * 当前委托  should not Unsub
     *
     * @param symbol
     * @param observer
     */
    public static void SubFuturesSymbolOrderChange(String symbol, SimpleResponseListener<EntrustOrderResponse> observer) {

        TradeDataManager.GetInstance().RequestFuturesSymbolOrder(symbol, observer);
    }

    /**
     * 当前委托（所有订单） should not Unsub
     *
     * @param observer
     */
    public static void SubFuturesOrderChange(SimpleResponseListener<EntrustOrderResponse> observer) {

        TradeDataManager.GetInstance().RequestFuturesOrder(observer);
    }

    /**
     * 持仓订单  should not Unsub
     *
     * @param symbol
     * @param observer
     */
    public static void SubFuturesHoldOrderChange(String symbol, SimpleResponseListener<FuturesPositionOrderResponse> observer) {

        TradeDataManager.GetInstance().RequestFuturesHoldOrder(symbol, observer);
    }

    /**
     * 持仓订单（所有订单）  should not Unsub
     *
     * @param observer
     */
    public static void SubFuturesHoldOrderChange(SimpleResponseListener<FuturesPositionOrderResponse> observer) {

        TradeDataManager.GetInstance().RequestFuturesHoldOrder(observer);
    }

    /** 订单 HTTP **************************************/

    /**
     * 查询订单
     *
     * @param order_id
     * @param observer
     */
    public static void RequestOrderDetailByOrderId(String order_id, SimpleResponseListener<FuturesOrderResponse> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_ORDER_DETAIL_GET)
//                .addParam("client_order_id", client_order_id)
                .addParam("order_id", order_id);
//                .addParam("type", type);//订单类型，参数：LIMIT=普通委托, STOP=计划委托
        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, FuturesOrderResponse.class, observer);
    }

    /**
     * 获取当前委托
     *
     * @param symbol_id
     * @param from_order_id
     * @param end_order_id
     * @param limit
     * @param time_range
     * @param type
     * @param observer
     */
    public static void RequestOpenOrder(String symbol_id, String from_order_id, String end_order_id, int limit, String time_range, String type, SimpleResponseListener<EntrustOrderResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_OPEN_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("end_order_id", end_order_id)
                .addParam("from_order_id", from_order_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range)
                .addParam("type", type);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, EntrustOrderResponse.class, observer);
    }


    /**
     * 获取止盈止损 - 当前委托
     *
     * @param symbol_id
     * @param from_order_id
     * @param end_order_id
     * @param limit
     * @param time_range
     * @param observer
     */
    public static void getStopProfitLossData(String symbol_id, String from_order_id, String end_order_id, int limit, String time_range,SimpleResponseListener<EntrustOrderResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_STOP_PROFIT_LOSS_OPEN_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("end_order_id", end_order_id)
                .addParam("from_order_id", from_order_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, EntrustOrderResponse.class, observer);
    }

    /**
     * 获取止盈止损 - 历史委托
     *
     * @param symbol_id
     * @param from_order_id
     * @param end_order_id
     * @param limit
     * @param time_range
     * @param observer
     */
    public static void getHistoryStopProfitLossData(String symbol_id, String from_order_id, String end_order_id, int limit, String time_range,SimpleResponseListener<EntrustOrderResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_STOP_PROFIT_LOSS_HISTORY_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("end_order_id", end_order_id)
                .addParam("from_order_id", from_order_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, EntrustOrderResponse.class, observer);
    }


    /**
     * 获取当前持仓
     *
     * @param symbol_id
     * @param exchange_id
     * @param from_position_id
     * @param end_position_id
     * @param limit
     * @param time_range
     * @param listener
     */
    public static void RequestHoldOrders(String symbol_id, String exchange_id, String from_position_id, String end_position_id, int limit, String time_range, SimpleResponseListener<FuturesPositionOrderResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_CURRENT_HOLD_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("exchange_id", exchange_id)
                .addParam("from_position_id", from_position_id)
                .addParam("end_position_id", end_position_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range)
                .build();
        HttpUtils.getInstance().request(params, FuturesPositionOrderResponse.class, listener);
    }

    /**
     * 期货历史委托
     *
     * @param symbol_id
     * @param exchange_id
     * @param from_order_id
     * @param end_order_id
     * @param limit
     * @param time_range
     * @param type
     * @param listener
     */
    public static void RequestHistoryEntrustOrders(String symbol_id, String exchange_id, String from_order_id, String end_order_id, int limit, String time_range, String type, SimpleResponseListener<EntrustOrderResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_HISTORY_ENTRUST_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("exchange_id", exchange_id)
                .addParam("from_order_id", from_order_id)
                .addParam("end_order_id", end_order_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range)
                .addParam("type", type)
                .build();
        HttpUtils.getInstance().request(params, EntrustOrderResponse.class, listener);
    }

    /**
     * 期货历史成交
     *
     * @param symbol_id
     * @param exchange_id
     * @param from_trade_id
     * @param end_trade_id
     * @param limit
     * @param time_range
     * @param listener
     */
    public static void RequestHistoryDeliveryOrders(String symbol_id, String exchange_id, String from_trade_id, String end_trade_id, int limit, String time_range, SimpleResponseListener<DeliveryOrderResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_HISTORY_DEALED_ORDERS)
                .addParam("symbol_id", symbol_id)
                .addParam("exchange_id", exchange_id)
                .addParam("from_trade_id", from_trade_id)
                .addParam("end_trade_id", end_trade_id)
                .addParam("limit", limit)
                .addParam("time_range", time_range)
                .build();
        HttpUtils.getInstance().request(params, DeliveryOrderResponse.class, listener);
    }

    /**
     * 期货成交详情
     *
     * @param order_id
     * @param trade_id
     * @param limit
     * @param listener
     */
    public static void RequestHistoryDeliveryOrdersDetail(String order_id, String trade_id, int limit, SimpleResponseListener<DeliveryOrderResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_HISTORY_DEALED_ORDERS_DETAIL)
                .addParam("order_id", order_id)
                .addParam("trade_id", trade_id)
                .addParam("limit", limit)
                .build();
        HttpUtils.getInstance().request(params, DeliveryOrderResponse.class, listener);
    }

    /**
     * 期货成交详情
     *
     * @param underlying_id      标的ID
     * @param from_settlement_id
     * @param end_settlement_id
     * @param limit
     * @param listener
     */
    public static void RequestDeliveryRecords(String underlying_id, String from_settlement_id, String end_settlement_id, int limit, SimpleResponseListener<DeliveryRecordResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_FUTURES_DELIVERY_RECORD)
                .addParam("underlying_id", underlying_id)
                .addParam("from_settlement_id", from_settlement_id)
                .addParam("end_settlement_id", end_settlement_id)
                .addParam("limit", limit)
                .build();
        HttpUtils.getInstance().request(params, DeliveryRecordResponse.class, listener);
    }


    /**
     * 获取期货下单配置 费率 风险限额
     */
    public static void getFuturesCreateOrderConfig(String exchangeId, String symbolsIds, SimpleResponseListener<FuturesCreateOrderConfigResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_GET_CREATE_ORDER_CONFIG)
                .addParam(Fields.FIELD_EXCHANGE_ID2, exchangeId)
                .addParam(Fields.FIELD_SYMBOL_IDS, symbolsIds);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, FuturesCreateOrderConfigResponse.class, observer);

    }

    /**
     * 合约计算器-计算收益信息
     */
    public static void calculateProfitInfo(int isLong, String symbolId,String leverage,String openPrice,String openQuantity,String closePrice,String closeQuantity, SimpleResponseListener<CalculateProfitResponse> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_CALCULATOR_PROFIT)
                .addParam("symbol_id", symbolId)
                .addParam("is_long", isLong)
                .addParam("leverage", leverage)
                .addParam("open_price", openPrice)
                .addParam("open_quantity", openQuantity)
                .addParam("close_price", closePrice)
                .addParam("close_quantity", closeQuantity);
        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, CalculateProfitResponse.class, observer);

    }

    /**
     * 合约计算器-计算强平价
     */
    public static void calculateLiquidationPrice(int isLong, String symbolId,String leverage,String openPrice,String openQuantity,String marginCall, SimpleResponseListener<CalculateLiquidationPriceResponse> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_CALCULATOR_LIQUIDATION)
                .addParam("symbol_id", symbolId)
                .addParam("is_long", isLong)
                .addParam("leverage", leverage)
                .addParam("open_price", openPrice)
                .addParam("open_quantity", openQuantity)
                .addParam("margin_call", marginCall);
        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, CalculateLiquidationPriceResponse.class, observer);

    }

    /**
     * 期货下单
     *
     * @param observer
     */
    public static void orderCreate(OrderCreateParams params, SimpleResponseListener<FuturesOrderResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_ORDER_CREATE)
                .addParam("exchange_id", params.exchangeId)
                .addParam("client_order_id", params.clientOrderId)
                .addParam("symbol_id", params.symbolId)
                .addParam("side", params.side)
                .addParam("type", params.type)
                .addParam("price", params.price)
                .addParam("trigger_price", params.triggerPrice)
                .addParam("price_type", params.priceType)
                .addParam("quantity", params.quantity)
                .addParam("leverage", params.leverage);
        PostParams postParam = builder.build();
        HttpUtils.getInstance().request(postParam, FuturesOrderResponse.class, observer);

    }

    /**
     * 期货撤单
     *
     * @param clientOrderId 客户端订单Id
     * @param orderId       交易订单id
     * @param type          (可选参数) 订单类型，参数：
     *                      LIMIT=普通委托
     *                      STOP=计划委托
     *                      默认=LIMIT
     * @param observer
     */
    public static void orderCancel(String clientOrderId, String orderId, String type, SimpleResponseListener<ResultResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_ORDER_CANCEL)
                .addParam("client_order_id", clientOrderId)
                .addParam("order_id", orderId)
                .addParam("type", type);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, ResultResponse.class, observer);

    }

    /**
     * 期货批量撤单
     * symbolIds 不传撤所有订单
     */
    public static void orderBatchCancel(String symbolIds, SimpleResponseListener<ResultResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_ORDER_BATCH_CANCEL)
                .addParam("symbol_ids", symbolIds);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, ResultResponse.class, observer);

    }

    /**
     * 期货标的列表
     */
    public static void getUnderlyingList(SimpleResponseListener<TradableBeanResponse> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_UNDERLYING_LIST);
        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, TradableBeanResponse.class, observer);

    }

    /**
     * 调整保证金（增加、减少）
     * @param symbolId 合约symbol id
     * @param type 类型:  INC = 增加， DEC = 减少
     * @param amount 保证金token数量。（备注：增加或减少时，输入的都是正值）
     * @param holdType 仓位信息：1= 开多， 0 = 开空
     * @param observer
     */
    public static void adjustMargin(String symbolId, String type, String amount, String holdType, SimpleResponseListener<ResultResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_MODIFY_MARGIN)
                .addParam("symbol_id", symbolId)
                .addParam("type", type)
                .addParam("amount", amount)
                .addParam("is_long", holdType);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, ResultResponse.class, observer);

    }

    /**
     * 设置风险限额
     * @param symbolId
     * @param riskLimitId 风险限额id
     *
     * @param side  订单方向，参数：
     *
     * 开仓买入=BUY_OPEN
     *
     * 开仓卖出=SELL_OPEN
     *
     * 备注："开仓"需要设置风险限额，"平仓"不需要设置风险限额。
     * @param observer
     */
    public static void setRiskLimit(String symbolId, String riskLimitId, String side, SimpleResponseListener<ResultResponse> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_SET_RISK_LIMIT)
                .addParam("symbol_id", symbolId)
                .addParam("risk_limit_id", riskLimitId)
                .addParam("side", side);
        PostParams params = builder.build();
        HttpUtils.getInstance().request(params, ResultResponse.class, observer);

    }

    /**
     * 获取资金费率
     * @param observer
     */
    public static void getFundingRates(SimpleResponseListener<FuturesFundingRatesResponse> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_FUNDING_RATES);
        GetParams params = builder.build();
        HttpUtils.getInstance().request(params, FuturesFundingRatesResponse.class, observer);

    }

    /**
     * 获取止盈止损信息
     * @param observer
     */
    public static void getStopProfitLossInfo(String symbolId,String islong,SimpleResponseListener<FutureStopProfitLossInfo> observer) {

        GetParams.Builder builder = new BParamsBuilder().get();
        builder.url(Urls.API_FUTURES_STOP_PROFIT_LOSS_GET);
        GetParams params = builder
                .addParam("symbol_id",symbolId)
                .addParam("is_long",islong)
                .build();
        HttpUtils.getInstance().request(params, FutureStopProfitLossInfo.class, observer);

    }

    /**
     * 设置止盈止损价格
     * @param STOP_PROFIT_TRIGGER_PRICE_TYPE
     * @param STOP_PROFIT_CLOSE_POSITION_TYPE
     * @param STOP_LOSS_TRIGGER_PRICE_TYPE
     * @param STOP_LOSS_CLOSE_POSITION_TYPE
     * @param observer
     */
    public static void setStopProfitLossPrice(String symbolId, String exchangeId, String islong, String profitPrice, int STOP_PROFIT_TRIGGER_PRICE_TYPE, int STOP_PROFIT_CLOSE_POSITION_TYPE, String lossPrice, int STOP_LOSS_TRIGGER_PRICE_TYPE, int STOP_LOSS_CLOSE_POSITION_TYPE, SimpleResponseListener<FutureStopProfitLossInfo> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_STOP_PROFIT_LOSS_SET);
        PostParams params = builder
                .addParam("symbol_id",symbolId)
                .addParam("exchange_id",exchangeId)
                .addParam("is_long",islong)
                .addParam("stop_profit_price",profitPrice)
                .addParam("stop_loss_price",lossPrice)
                .addParam("sp_trigger_condition_type",STOP_PROFIT_TRIGGER_PRICE_TYPE)
                .addParam("sp_close_type",STOP_PROFIT_CLOSE_POSITION_TYPE)
                .addParam("sl_trigger_condition_type",STOP_LOSS_TRIGGER_PRICE_TYPE)
                .addParam("sl_close_type",STOP_LOSS_CLOSE_POSITION_TYPE)
                .build();
        HttpUtils.getInstance().request(params, FutureStopProfitLossInfo.class, observer);

    }

    /**
     * 取消止盈止损价格
     * @param observer
     *
     *cancelType  取消类型 1=取消止盈 2=取消止损 3=取消全部 默认取消全部
     */
    public static void cancelStopProfitLossPrice(String symbolId,String islong,int cancelType,SimpleResponseListener<FutureStopProfitLossInfo> observer) {

        PostParams.Builder builder = new BParamsBuilder().post();
        builder.url(Urls.API_FUTURES_STOP_PROFIT_LOSS_CANCEL);
        PostParams params = builder
                .addParam("symbol_id",symbolId)
                .addParam("is_long",islong)
                .addParam("cancel_type",cancelType) //取消类型 1=取消止盈 2=取消止损 3=取消全部 默认取消全部
                .build();
        HttpUtils.getInstance().request(params, FutureStopProfitLossInfo.class, observer);

    }

}
